const md5 = require('../../../../utils/md5.js');
const http = require('../../../../utils/http.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        msg: [{ name: '设备损坏', "state": 0 }, { name: '断网', "state": 0 }, { name: '插头松动', "state": 0 }, { name: '显示器故障', "state": 0 }, { name: '线路故障', "state": 0 }, { name: '主机故障', "state": 0 }, { name: '逻辑故障', "state": 0 }, { name: '其他', "state": 0 }],
        img: {
            img: '/images/k4.png'
        },
        checkFail: [],
        feedBack: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },
    clickSubmit() {
        let _this = this
        let data = {
            method: 'Feedback.feedback',
            type: 3,
            tags: _this.data.checkFail,
            describe: _this.data.feedBack,
            token: wx.getStorageSync('token')
        }
        let arr = http.sorts(data)
        //console.log(arr)
        data.sign = md5.hex_md5(arr)
        http._post(data, res => {
            console.log(res)
            if (res.data.code == 0) {
                wx.showToast({
                    title: res.data.msg,
                    icon: 'none',
                    duration: 1000
                })
            } else {
                wx.showToast({
                    title: res.data.msg,
                    icon: 'none',
                    duration: 1500
                })
            }
        })
    },
    changeColor(e){
        console.log(e.detail)
        this.setData({
            checkFail:e.detail
        })
    },
    clickload(e){
        console.log(e.detail)
    },
    userText(e){
        console.log(e.detail)
        this.setData({
            feedBack:e.detail
        })
    },
    clearLoadImg(e){
        console.log(e.detail)
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})